home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Sound / LAME / WarpOS / src / misc / Lame.vbs < prev    next >
Encoding:
Text File  |  2001-06-14  |  3.9 KB  |  137 lines

  1. ' lame.vbs WindowsScript wrapper v0.4, 06/2001
  2. ' $id$
  3. '
  4. ' *Purpose*
  5. ' Use this WindowsScript to encode WAVs using drag&drop:
  6. ' 0.  make sure you have windows script host v2.0 on your system
  7. '     (enter 'cscript' in a DOS-Box, you should have version >=5.0)
  8. ' 1.  adjust the path settings below to fit your needs
  9. ' 2a. put this file somewhere on the desktop
  10. ' 3a. drag one or more wav-files on the icon and watch them being lamed.
  11. '
  12. ' 2b. start->execute, enter "sendto", drag the script or a link to it in
  13. '     sendto window (adjust names and icon as you like)
  14. ' 3b. select wave-file(s) and send it via the send-to menu to LAME!
  15. '
  16. ' You may wish to create copies of this file with different options set.
  17. '
  18. ' If you would like a GUI: try to enable the HTML UI (see below)
  19. '
  20. ' Ralf Kempkens, ralf.kempkens@epost.de
  21. '
  22. '
  23. ' *History*
  24. ' V0.4 * creates single .mp3 extensions, now ID3 options in HTML interface
  25. ' V0.3 * fixed bug that prevented lame.exe to be located in a path that 
  26. '        contained a space
  27. '      * experimental HTML UI support (disabled by default)
  28. ' V0.2 added multiple file support
  29. ' V0.1 initial release
  30.  
  31. ' *** change path to your needs ***
  32.     path = "D:\Audio\Lame\"
  33.     lame = "lame.exe"
  34.  
  35. ' *** change default options to your needs ***
  36.     opts = "--preset cd"
  37.  
  38. ' *** HTML GUI (experimental) ***
  39.     useGUI = False
  40. ' it set to True, opens file lameGUI.html residing in the same path as lame.exe
  41. ' to choose options. Please look at the HTML-file for further information.
  42.  
  43. ' no changes needed below this line
  44. ' ##########################################################################
  45. Dim wsh, args, infile, fs
  46. title="LAME Script"
  47.  
  48. ' get input files
  49. Set wsh = WScript.CreateObject("WScript.Shell")
  50. Set args = WScript.Arguments
  51. If args.Count = 0 Then
  52.   MsgBox "Please use drag & drop to specify input files.", vbInformation, title
  53.   WScript.Quit
  54. End If
  55.  
  56. ' check path
  57. Set fs = CreateObject("Scripting.FileSystemObject")
  58. If Not fs.FileExists(path & lame) Then
  59.   wsh.Popup "Could not find LAME!" & vbCR & "(looked for '" & lame & "')", ,title, 16
  60.   WScript.Quit
  61. End If
  62.  
  63. ' start GUI
  64. if useGUI Then
  65.   set ie=WScript.CreateObject("InternetExplorer.Application", "ie_")
  66.   ie.navigate(path & "lameGUI.html")
  67.   do 
  68.     WScript.Sleep 100 
  69.   loop until ie.ReadyState=4 'wait for GUI
  70.  
  71.   ie.Width=640
  72.   ie.Height=600
  73.   ie.Toolbar=false
  74.   ie.Statusbar=false
  75.   ie.visible=true
  76.  
  77.   'link to GUI
  78.   set document=ie.document
  79.   document.forms.lameform.okbutton.onClick=GetRef("okbutton")
  80.  
  81.   'wait for user pressing ok...
  82.   do 
  83.     WScript.Sleep 300 
  84.   loop until process
  85. end if
  86.  
  87. 'process files
  88. For i = 0 To args.Count-1
  89.   infile = args(i)
  90.   ' check input file
  91.   If Not fs.FileExists(infile) Then
  92.     wsh.Popup "Error opening input-file" & vbCR & "'" & infile & "'", ,title, 16
  93.   Else
  94.     ' run lame
  95.     ret = wsh.Run(CHR(34) & path & lame & CHR(34) & Chr(32) & opts & Chr(32) & _
  96.           Chr(34) & infile & Chr(34) & Chr(32) & Chr(34) & _
  97.           getBasename(infile) & ".mp3" & Chr(34), 1, True)
  98.  
  99.     ' diagnostics
  100.     Select Case ret
  101.     Case (-1)
  102.       MsgBox "LAME aborted by user!", vbExclamation, title
  103.     Case (1)
  104.       MsgBox "Error returned by LAME!" & vbCR & "(Check LAME options and input file formats.)" & vbCR & "Used Options: " & opts, vbCritical, title
  105.     Case Else
  106.       Rem ignore
  107.     End Select
  108.   End If
  109. Next
  110.  
  111. WScript.Quit
  112. ' *******************************************************************
  113. ' utility functions
  114.  
  115. Function getBasename(filespec)
  116.   Dim fso
  117.   Set fso = CreateObject("Scripting.FileSystemObject")
  118.   Set f = fso.GetFile(filespec)
  119.   
  120.   getBasename = f.ParentFolder & "\" & fso.GetBaseName(filespec)
  121. End Function
  122.  
  123. ' *******************************************************************
  124. ' manage link to IE HTML-interface
  125.  
  126. sub okbutton
  127.   'process inputs
  128.   opts=document.all.lameoptions.Value
  129.   ie.Quit
  130.   MsgBox "LAME options:" & vbCR & opts, vbInformation, title
  131. end sub
  132.  
  133. sub ie_onQuit
  134.   process=True
  135. end sub
  136. 'eof
  137.